-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: os/posix: port of the posix implementation to macOS #352
WIP: os/posix: port of the posix implementation to macOS #352
Conversation
56fd998
to
9e52bca
Compare
Wow... lots to digest in here. I took a quick skim through and it seems there are quite a few different things that this addressing. It would be helpful if this could somehow be broken into smaller, more easily digestible change sets for review. We will have to have some discussions on with the broader user community on the right way to proceed here. I was hoping that most of the changes could be done in such a way where it would be limited to some small variation on the POSIX implementation. |
9e52bca
to
0f0857d
Compare
Yes, it is a lot. And this is why I have annotated every change with a comment which explains why I have to make it. It would be possible to reduce the size of the diff to certain extent but I am afraid that most of it is taken by the I can comment on the changeset on everything where I think the parts could be considered standalone and if these parts are confirmed I can create corresponding separate Pull Requests for them. I will start doing comments now.
I would like to get at least one confirmation from a macOS user that this branch works fine for them. From my side, I am fully committed to making this work ready to be merged if there is a general interest in having a macOS port in the tree. |
@@ -0,0 +1,34 @@ | |||
|
|||
|
|||
test: test.unit test.integration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the first obvious candidate for removal or extraction. I have not found a single place in the osal from where I can run ALL unit and integration tests. I suspect that there is some private branch of nasa/osal
where such script exists.
Having such a "one-click" solution for running all of the tests is essential for making sure that the osal is not broken when making changes and testing them on both Linux and macOS.
Please advise if I should remove this custom Makefile
and rather use some existing test scripts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this will satisfy it: #403.
posix-mac-addons/CMakeLists.txt
Outdated
@@ -0,0 +1,22 @@ | |||
cmake_minimum_required(VERSION 3.13) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will not comment on any of the posix-mac-addons
now. The cleanups and further improvements are tracked here: https://github.com/stanislaw/posix-mac-addons/issues. For the time being, I will be force-pushing or adding some cleanups to this branch while also re-running the tests with the test Makefile
from this changeset.
# TODO-MAC: | ||
# Forcing eeprom1 to be in CMAKE_BINARY_DIR. | ||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/eeprom1) | ||
target_link_libraries(osal_loader_UT MODULE${MOD}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This specific line target_link_libraries...
can be extracted to a separate PR also with the add_osal_ut_exe
line moved above like on the diff.
The LIBRARY_OUTPUT_DIRECTORY
will be a separate discussion.
254bd63
to
a5d2ffd
Compare
I have updated this PR's description as well. It is also my individual contribution. |
4e0b254
to
d60891f
Compare
d60891f
to
fe22563
Compare
69f92d8
to
6011517
Compare
@@ -18,8 +18,8 @@ target_link_libraries(osal_bsp | |||
# Note - although GCC understands the same flags for compile and link here, this may | |||
# not be true on all platforms so the compile and link flags are specified separately. | |||
if (NOT CMAKE_CROSSCOMPILING) | |||
set(UT_COVERAGE_COMPILE_FLAGS -pg --coverage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened here: #420.
/// Current working dir: /sandbox/cFS/osal/build.commandline.dir | ||
/// [ FAIL] 04.004 ut_osloader_symtable_test.c:186 - #4 Nominal | ||
/// [ END] 04 OS_SymbolLookup TOTAL::4 PASS::3 FAIL::1 MIR::0 TSF::0 N/A::0 | ||
Function = dlsym((void *)OSAL_DLSYM_DEFAULT_HANDLE, SymbolName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #214.
56eeb61
to
f235a8a
Compare
698a2b3
to
0f0969e
Compare
@@ -4,7 +4,9 @@ set(TEST_MODULE_FILES | |||
ut_osloader_module_test.c | |||
ut_osloader_symtable_test.c | |||
ut_osloader_test.c) | |||
|
|||
|
|||
add_osal_ut_exe(osal_loader_UT ${TEST_MODULE_FILES}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened as a separate one here: #431.
a2e317a
to
8c1b8ff
Compare
8c1b8ff
to
329ea9c
Compare
@jphickey @skliper I would like to hear your thoughts on the following topic: I know that you are hesitant to consider merging this as a separate However I have to work with cFS in a real development rather soon (in one or two months) and I will have to maintain both Linux and macOS support for our cFS-based software and so far I could not find an easy way of keeping both Linux and macOS variants of I have removed the Any advice on how I could integrate it in my downstream private fork would be highly appreciated. Thank you. |
@stanislaw you'll want to check out the merges that are going into PR #427 first. This breaks up all the impl subsystems (queues, timers, mutexes, etc) into separate subsystems in separate source files. That means rather than maintaining patches to files, you should be able to just maintain entirely separate files (i.e. a separate mac-queue or mac-timer source file perhaps) and select which one you build based on CMAKE variables. I think this will be easier for you. As far as a longer term solution goes, I think there is probably community interest in getting OSX support "out of the box" in the framework, but that's at least a few months out as NASA has other near-term objectives to meet right now. But I do think making these into separate subsystem-level source files will help a lot in the near term, not only for your needs but also if/when we do merge this sometime in the future we can review each subsystem independently. |
Heads up - format cleanup is likely coming soon which will create many merge conflicts for any pending PRs. This one looks like a significant number of merge conflicts have built up already... |
@skliper thanks for the heads up. I could try rebasing the whole PR on top of the latest master but let me know if it is worth doing this. I saw some hesitation by @jphickey about integrating this PR as is (this comment: #352 (comment)). My understanding is that even if I polished this PR to green it would still not be considered mergeable because the POSIX addons for macOS are something you maintainers would prefer to not integrate as a macOS-specific and therefore too custom OSAL and instead you want to spend an indefinite amount time on making the POSIX OSAL portable enough to accomodate for Linux AND BSD* including macOS. On my side, I am happy to volunteer here and do whatever it takes to integrate these changes into the cFS tree. Just let me know if there is a way of doing this using this changeset. |
I think there are users out there that would definitely appreciate having some OSX support.... but the NASA projects that are currently pushing CFE/OSAL development don't require it, so it will likely have to be a volunteer effort. The main issues to solve here are integration and some form of a test/CI plan. Integration is a big one - we can't break POSIX (or any other platform). And if we are to support this platform we need a plan to validate it - we already have platforms which are not tested on a regular basis, and as a result we get breakage on those platforms. Doing a "clone and own" approach is fast and easy - but yields a result that is hard to maintain because its constantly falling behind its counterpart - especially if there isn't a CI plan in place. That's the reason I push for minimal duplication - reuse all code where possible, clone/modify only the specific subsections you really need to change. The specifics of how the code is organized (i.e. whether part of POSIX or a separate OSX layer) isn't as important - we can go either way - as long as the result is well integrated and maintainable/testable. |
Thank you for your answer. I totally agree with everything you have said. I could do the following exercise when I find a good time slot for it in the near future (1-2 weeks):
Let me know if this sounds right to you. |
I looked into a mac port a long time ago. I then started looking at using qt to abstract the system calls. |
Closing this in favour of #1161. |
Describe the contribution
This is an ongoing attempt to make the CFS / OSAL work on macOS. I am opening this is as a Work-in-Progress Pull Request because there are many things that have to be addressed.
Rough plan of the work (major points):
Makefile
are passing. One could use this Makefile as a starting point for working with this changeset.#ifdef
s. I would go with the approach 1 with a separate macos folder to maintain clear distinction between Linux and macOS given that macOS will most likely always be only a development/simulation target which means that the lack of thert
stuff on macOS is not a problem and its simulation is ok.main
of src/bsp/pc-linux/src/bsp_start.c conflicts with themain
of the unit tests. Open and fixed here: "duplicate symbol '_main'" on macOS when building tests #363..tbl
files on macOS.Some important comments:
It is not the first time that I am trying to make something work on macOS so I had some code in my pockets already. I have collected the POSIX functions which were missing on macOS to a separate project: posix-mac-addons. For now, I am simply copying the
src
contents of that project to the root of theosal
repository. Please see the comments on the implemented functions on that project's README page as well.I have built this branch from 2 different macOS machines and I can confirm that everything seems to work on my end: building them from a clean tree and running the tests. Both are Mojave though, so I cannot promise that everything will work on Catalina (many things are breaking for those who have upgraded so upgrading this changeset to Catalina could be a separate action).
All of the tests as found in the changeset's
Makefile
are passing. One could use this Makefile as a starting point for working with this changeset.I was not sure whether I should have created the
posix-mac
port or simply hack on top ofposix
. I decided to go for latter because it is now easier to see on the diff what is different. However, if there is an interest in getting this merged, it is not clear to me what would be the right solution: keepposix
with lots of ifs or create a dedicatedmac-posix
one.Both implementations of the semaphores are passing the tests. This changeset is using the one which is
mac_sem2_*
based on the GCD semaphores. The following important detail explains why the implementation is a bit more sophisticated. Without this detail some of the tests are crashing. I guess, this could be fixed by simply ensuring that the semaphores in the tests are used in a balanced way.Testing performed
The testing has been performed on macOS Mojave 10.14.6
Expected behavior changes
System(s) tested on
Additional context
Everything is in the description.
Third party code
This is to be defined very soon. 2/3 of the code in
posix-mac-addons
is created because of my work on this port but I would really like to haveposix-mac-addons
available as a standalone repository that will have a MIT license. I would like to know your thoughts on if / how this third-party code could be integrated then.Contributor Info - All information REQUIRED for consideration of pull request
Stanislav Pankevich, personal
The signed individual CLA has been sent to the email specified in the CLA document.